package com.longge;

import java.util.Stack;

/**
 * @创建人 xinglongge
 * @创建时间 2021/12/5
 * @描述
 */
public class CalPoints {
    public int calPoints(String[] ops) {
        Stack<Integer> stack = new Stack<>();
        for (String op : ops) {
            if (op.equals("+")) {
                Integer pop1 = stack.pop();
                Integer pop2 = stack.pop();
                stack.push(pop1);
                stack.push(pop2);
                stack.push(pop1 + pop2);
            } else if (op.equals("C")) {
                stack.pop();
            } else if (op.equals("D")) {
                stack.push(stack.peek() * 2);
            } else {
                stack.push(Integer.valueOf(op));
            }
        }

        return stack.stream().mapToInt(i -> i).sum();
    }

    public static void main(String[] args) {
        int i = 1000000;
        System.out.println(i);
    }
}
